Skip to content

Fix reconcile loop when Postgres CR is not found#284

Open
pcallewaert wants to merge 2 commits intomasterfrom
fix/fix-reconcile-loop
Open

Fix reconcile loop when Postgres CR is not found#284
pcallewaert wants to merge 2 commits intomasterfrom
fix/fix-reconcile-loop

Conversation

@pcallewaert
Copy link
Contributor

This should resolve the issue in #115

@pcallewaert pcallewaert self-assigned this Dec 24, 2025
@pcallewaert pcallewaert marked this pull request as ready for review December 24, 2025 09:49
Copy link

@pretzelmaker pretzelmaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on! I think this is a great start.

I did notice that by returning ctrl.Result{}, nil in the scenario that the Postgres CR is not found, eventual consistency will be broken. Let me explain.

Currently, if a user applies a Postgres CR and a PostgresUser CR at the same time, or if the Posgtres CR is created after the user, the code will catch that the database is missing and the PostgresUser will not get reconciled again until the CR is updated or the operator is restarted. This breaks the idea of eventual consistency.

I think best way to go about addressing this issue in the "kubernetes way" would be to have a cross-resource watch of the Postgres CR in the SetupWithManager function. This way, PostgresUsers will only get created once changes on Postgres CRs are detected. There are pros/cons to this approach, such as a situation where the Postgres database is not managed by the operator, but we should be able to account for this.

@pcallewaert pcallewaert force-pushed the fix/fix-reconcile-loop branch from b8223ab to 6878317 Compare February 4, 2026 14:47
@pcallewaert
Copy link
Contributor Author

@pretzelmaker Great feedback! I implemented the cross resource watch. Is this what you were thinking about?

@pcallewaert pcallewaert requested a review from hitman99 February 4, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants